package mod.luckymod.data;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.concurrent.CompletableFuture;

import static mod.luckymod.Luckymod.MODID;

//这个类相当于对所有的json数据生成器的一个管理，都添加到generator身上即可
@Mod.EventBusSubscriber(modid = MODID,bus=Mod.EventBusSubscriber.Bus.MOD)
public class DataGenerators {

    //这个注释表明这个方法要被模组事件总线所监视，这个方法是事件触发时的回调
    @SubscribeEvent
    public static void gatherData(GatherDataEvent event){
        DataGenerator generator=event.getGenerator();
        PackOutput output = generator.getPackOutput();
        CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
        generator.addProvider(event.includeServer(),new ModWorldGen(output,lookupProvider));
        //添加生成方块json文件的类
        generator.addProvider(event.includeClient(),new RecipeGenerator(generator));

    }
}